package com.wangyi;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

/**
 * 网易第二题
 */
public class test2 {

    static int[][] Matrix;


    static ArrayList<int[]> res = new ArrayList<>();

    static int n;

    private static int colCount = 0, rowCount = 0;

    private static HashSet<Integer> colHasCut = new HashSet<>();

    private static HashSet<Integer> rowHasCut = new HashSet<>();

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
           String N = in.nextLine();
           n = Integer.valueOf(N);
            Matrix = new int[n+1][n+1];
            colCount = n; rowCount = n;
            for(int i = 1; i < n+1; i++){
                for(int j = 1; j < n+1; j++){
                    int element = in.nextInt();
                    Matrix[j][i] = element;
                }
            }
            while(colCount>0 && rowCount >0){
                cut();
            }

            res.forEach( e -> System.out.println(e[0]+" "+e[1]));
        }
    }



    public static void cut(){
        int maxCol = 0, maxRow = 0;
        int preRow = 0;
        int preCol = 0;
        int sum;
        int maxSum = Integer.MIN_VALUE;
        for(int i = 1; i<=n; i++){
            if(rowHasCut.contains(i)) {
                continue;
            }
            for(int j = 1; j<=n; j++){
                if(colHasCut.contains(j)){
                    continue;
                }
                sum = getCutSum(i,j);
                if(sum > maxSum){
                    maxRow = i;
                    maxCol = j;
                    maxSum = sum;
                }
            }
        }
        for(int i = 1; i<=n; i++){
            if(rowHasCut.contains(i) && i < maxRow)
                preRow++;
        }

        for(int i = 1; i<=n; i++){
            if(colHasCut.contains(i) && i < maxCol)
                preCol++;
        }

        res.add(new int[]{maxRow-preRow, maxCol-preCol});
        colHasCut.add(maxCol);
        colCount--;
        rowHasCut.add(maxRow);
        rowCount--;
    }

    public static int getCutSum(int row, int col){
        int sum = 0;
        for(int i = 1; i<=n; i++){
            if(!colHasCut.contains(i))
                sum += Matrix[row][i];
        }
        for(int i = 1; i<=n; i++){
            if(!rowHasCut.contains(i))
                sum += Matrix[i][col];
        }
        return sum - Matrix[row][col];
    }
}
